package sfmc.biz.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;

import sfmc.biz.dao.SfmcOldFileListDao;
import sfmc.biz.service.SfmcOldFileListService;
import sfmc.biz.vo.Sfmc_OLD_FILE_LIST;

@Service("SfmcOldFileListService")
public class SfmcOldFileListServiceImpl implements SfmcOldFileListService{
	
	protected Log log = LogFactory.getLog(this.getClass());
	
	@Resource(name="SfmcOldFileListDao")
	private SfmcOldFileListDao sfmcOldFileListDao;
	
	public void setSfmcCustomer(SfmcOldFileListDao sfmcOldFileListDao){
		this.sfmcOldFileListDao = sfmcOldFileListDao;
	}

	public List<Sfmc_OLD_FILE_LIST> getOldRecordList(Sfmc_OLD_FILE_LIST sfmc_OLD_FILE_LIST){
		
		String where = "";
		
		try{
			if(!"".equals(sfmc_OLD_FILE_LIST.getStatus())){
				where += "AND status = '" + sfmc_OLD_FILE_LIST.getStatus() + "'\n";
			}
			if(!"".equals(sfmc_OLD_FILE_LIST.getGroupNo())){
				where += "AND groupNo = '" + sfmc_OLD_FILE_LIST.getGroupNo() + "'\n";
			}
			if(!"".equals(where)){
				sfmc_OLD_FILE_LIST.setWhere(where);
			}
			return sfmcOldFileListDao.getOldRecordList(sfmc_OLD_FILE_LIST);
		}catch(Exception e){
			log.error(e);
			return null;
		}
	}
	
	public int getOldRecordCount(Sfmc_OLD_FILE_LIST sfmc_OLD_FILE_LIST){
		
		String where = "";
		
		try{
			if(!"".equals(sfmc_OLD_FILE_LIST.getStatus())){
				where += "AND status = '" + sfmc_OLD_FILE_LIST.getStatus() + "'\n";
			}
			if(!"".equals(sfmc_OLD_FILE_LIST.getGroupNo())){
				where += "AND groupNo = '" + sfmc_OLD_FILE_LIST.getGroupNo() + "'\n";
			}
			if(!"".equals(where)){
				sfmc_OLD_FILE_LIST.setWhere(where);
			}
			return sfmcOldFileListDao.getOldRecordCount(sfmc_OLD_FILE_LIST);
		}catch(Exception e){
			log.error(e);
			return 0;
		}
	}
}
